<?php 
//Placeholder for functions
	function confirm_query($result_set) {
		if (!$result_set) {
			die("Database query failed: " . mysql_error());
		}
	}

	function redirect_to( $location = NULL ) {
		if ($location != NULL) {
			header("Location: {$location}");
			exit;
		}
	}

	function mysql_prep( $value ) {
		$magic_quotes_active = get_magic_quotes_gpc();
		$new_enough_php = function_exists( "mysql_real_escape_string" ); // i.e. PHP >= v4.3.0
		if( $new_enough_php ) { // PHP v4.3.0 or higher
			// undo any magic quote effects so mysql_real_escape_string can do the work
			if( $magic_quotes_active ) { $value = stripslashes( $value ); }
			$value = mysql_real_escape_string( $value );
		} else { // before PHP v4.3.0
			// if magic quotes aren't already on then add slashes manually
			if( !$magic_quotes_active ) { $value = addslashes( $value ); }
			// if magic quotes are active, then the slashes already exist
		}
		return $value;
	}
	
	
	function access_check($actionid,$connection) {
		$sql = "SELECT * ";
		$sql .= " FROM `permition` ";
		$sql .= " WHERE `permition`.vartotojasid =  ";
		$sql .= $_SESSION['vartotojasid'];
		$sql .= " AND `permition`.actionid =  ";
		$sql .= $actionid ;
		$sql .= " LIMIT 1 ";
		
		//$connection = mysql_connect("localhost","test","qwerty");
		//echo "->".$connection."<-";
	
		$result_set = mysql_query($sql, $connection);
		
		$permition = mysql_fetch_array($result_set);
		
		if ($permition['allow']){} ELSE {echo "INVADERS!!!";};
		
		return $permition['allow'];
	}
	
	function substr_unicode($str, $s, $l = null) {
    return join("", array_slice(
        preg_split("//u", $str, -1, PREG_SPLIT_NO_EMPTY), $s, $l));
	}
?>